//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.jim.core.packets;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import java.io.Serializable;
import java.util.List;
import org.apache.commons.collections4.CollectionUtils;

public class User extends Message implements Serializable {
	private static final long serialVersionUID = 1L;
	private String userId;
	private String nickname;
	private String avatar;
	private String status;
	private String sign;
	private String terminal;
	private List<Group> friends;
	private List<Group> groups;

	private User() {
		this.status = UserStatusType.OFFLINE.getStatus();
	}

	private User(String userId, String nickname, String avatar, String status, String sign, String terminal, List<Group> friends, List<Group> groups, JSONObject extras) {
		this.status = UserStatusType.OFFLINE.getStatus();
		this.userId = userId;
		this.nickname = nickname;
		this.avatar = avatar;
		this.status = status;
		this.sign = sign;
		this.terminal = terminal;
		this.friends = friends;
		this.groups = groups;
		this.extras = extras;
	}

	public static Builder newBuilder() {
		return new Builder();
	}

	public String getUserId() {
		return this.userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getNickname() {
		return this.nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getAvatar() {
		return this.avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getSign() {
		return this.sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getTerminal() {
		return this.terminal;
	}

	public void setTerminal(String terminal) {
		this.terminal = terminal;
	}

	public List<Group> getFriends() {
		return this.friends;
	}

	public void setFriends(List<Group> friends) {
		this.friends = friends;
	}

	public List<Group> getGroups() {
		return this.groups;
	}

	public void setGroups(List<Group> groups) {
		this.groups = groups;
	}

	public User clone() {
		User cloneUser = new User();
		BeanUtil.copyProperties(this, cloneUser, new String[]{"friends", "groups"});
		return cloneUser;
	}

	public static class Builder extends Message.Builder<User, Builder> {
		private String userId;
		private String nickname;
		private String avatar;
		private String status;
		private String sign;
		private String terminal;
		private List<Group> friends;
		private List<Group> groups;

		public Builder() {
			this.status = UserStatusType.OFFLINE.getStatus();
		}

		public Builder userId(String userId) {
			this.userId = userId;
			return this;
		}

		public Builder nickname(String nickname) {
			this.nickname = nickname;
			return this;
		}

		public Builder avatar(String avatar) {
			this.avatar = avatar;
			return this;
		}

		public Builder status(String status) {
			this.status = status;
			return this;
		}

		public Builder sign(String sign) {
			this.sign = sign;
			return this;
		}

		public Builder terminal(String terminal) {
			this.terminal = terminal;
			return this;
		}

		public Builder addFriend(Group friend) {
			if (CollectionUtils.isEmpty(this.friends)) {
				this.friends = Lists.newArrayList();
			}

			this.friends.add(friend);
			return this;
		}

		public Builder addGroup(Group group) {
			if (CollectionUtils.isEmpty(this.groups)) {
				this.groups = Lists.newArrayList();
			}

			this.groups.add(group);
			return this;
		}

		protected Builder getThis() {
			return this;
		}

		public User build() {
			return new User(this.userId, this.nickname, this.avatar, this.status, this.sign, this.terminal, this.friends, this.groups, this.extras);
		}
	}
}
